package cn.jas.common.jascommon.util;


import java.lang.reflect.Field;
import java.util.Map;

/**
 * @program: sf_jijianjiancha-deploy
 * @description: 数据映射工具
 * @author: chen_mx
 * @create: 2019-04-16 16:27
 **/
public class ReflectEntityUtil {

    public  static Object  convertEntity(Map<String,Object> map,Class cls){
        Field []  fl=cls.getDeclaredFields();
        Object obj=null;
        try {
            obj= cls.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        for(Field  field:fl){
            field.setAccessible(true);
            try {
                field.set(obj,map.get(field.getName()));
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return obj;
    }


}
